package com.epoint.bookmanagement.bizlogic.borrowinfo;

import java.util.List;

import javax.xml.stream.events.StartDocument;

import com.epoint.bookmanagement.bizlogic.bookinfo.domain.BookInfo;
import com.epoint.bookmanagement.bizlogic.borrowinfo.domain.BorrowInfo;
import com.epoint.bookmanagement.dao.BookInfoDao;
import com.epoint.bookmanagement.dao.BorrowInfoDao;

/**
 * 
 * @author 
 *
 */
public class BorrowInfoService {

	BorrowInfoDao borrowInfoDao = new BorrowInfoDao();
	BookInfoDao bookInfoDao = new BookInfoDao();
	
	/**
	 * 查询列表数据，带有排序字段和排序方向
	 * @param pageIndex 页号
	 * @param pageSize 页面大小
	 * @param sortField 排序字段
	 * @param sortOrder 排序方向
	 * @return 结果
	 */
	public List<BorrowInfo> queryBorrowInfo(Integer pageIndex, Integer pageSize, String sortField, String sortOrder) {
		return borrowInfoDao.queryBorrowInfo(pageIndex, pageSize, sortField, sortOrder);
	}
	
	/**
	 * 生成borrowId
	 * @return id
	 */
	public String generalBorrowId() {
		return borrowInfoDao.generalBorrowId();
	}
	
	/**
	 * 新增借阅信息
	 * @param borrowInfo 借阅信息
	 * @return
	 */
	public int addBorrowInfo(BorrowInfo borrowInfo) {
		return borrowInfoDao.addBorrowInfoAndsubRemain(borrowInfo);
	}
	
	/**
	 * 删除单条借阅信息
	 * @param borrowId id
	 * @return
	 */
	public int deleteBorrowInfoByBorrowId(String borrowId) {
		return borrowInfoDao.deleteBorrowInfoByBorrowId(borrowId);
	}

	
	/**
	 * 归还图书
	 * @param borrowId 借阅id
	 * @param bookId 图书id
	 * @return
	 */
	public int returnBook(String borrowId, String bookId) {
		return borrowInfoDao.returnBook(borrowId, bookId);
	}
}
